package com.ly.heart.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.ly.common.utils.DateUtils;
import com.ly.common.utils.SecurityUtils;
import com.ly.common.utils.erp.SnowflakeIdWorker;
import com.ly.heart.mapper.GiftMapper;
import com.ly.heart.service.IGiftService;
import org.springframework.stereotype.Service;
import com.ly.heart.domain.GiftEntity;

import javax.annotation.Resource;

/**
 * 礼品基础信息Service业务层处理
 *
 * @author cxl
 * @date 2024-06-13
 */
@Service
public class GiftServiceImpl extends ServiceImpl<GiftMapper,GiftEntity> implements IGiftService {

    @Resource
    private GiftMapper giftMapper;

    /**
     * 查询礼品基础信息
     *
     * @param id 礼品基础信息ID
     * @return 礼品基础信息
     */
    @Override
    public GiftEntity selectGiftEntityById(String id)
    {
        return giftMapper.selectGiftEntityById(id);
    }

    /**
     * 查询礼品基础信息列表
     *
     * @param giftEntity 礼品基础信息
     * @return 礼品基础信息
     */
    @Override
    public List<GiftEntity> selectGiftEntityList(GiftEntity giftEntity)
    {
        return giftMapper.selectGiftEntityList(giftEntity);
    }

    /**
     * 新增礼品基础信息
     *
     * @param giftEntity 礼品基础信息
     * @return 结果
     */
    @Override
    public int insertGiftEntity(GiftEntity giftEntity)
    {
        giftEntity.setId(SnowflakeIdWorker.getInstance().nextStringId());
        giftEntity.setUserId(SecurityUtils.getLoginUser().getUser().getUserId());
        giftEntity.setCreateTime(DateUtils.getNowDate());
        return giftMapper.insertGiftEntity(giftEntity);
    }

    /**
     * 修改礼品基础信息
     *
     * @param giftEntity 礼品基础信息
     * @return 结果
     */
    @Override
    public int updateGiftEntity(GiftEntity giftEntity)
    {
        giftEntity.setChangeTime(DateUtils.getNowDate());
        return giftMapper.updateGiftEntity(giftEntity);
    }

    /**
     * 批量删除礼品基础信息
     *
     * @param ids 需要删除的礼品基础信息ID
     * @return 结果
     */
    @Override
    public int deleteGiftEntityByIds(String[] ids)
    {
        return giftMapper.deleteGiftEntityByIds(ids);
    }

    /**
     * 删除礼品基础信息信息
     *
     * @param id 礼品基础信息ID
     * @return 结果
     */
    @Override
    public int deleteGiftEntityById(String id)
    {
        return giftMapper.deleteGiftEntityById(id);
    }
}
